代理

分辨需要设置的代理

一、HTTP 形式

走 HTTP 代理

git config --global http.proxy "http://127.0.0.1:7890"
git config --global https.proxy "http://127.0.0.1:7890"

走 socks5 代理(如 Shadowsocks)

git config --global http.proxy "socks5://127.0.0.1:7890"
git config --global https.proxy "socks5://127.0.0.1:7890"

取消设置

git config --global --unset http.proxy
git config --global --unset https.proxy

二、SSH 形式

修改 ~/.ssh/config 文件(不存在则新建):

# 必须是 github.com
Host github.com
   HostName github.com
   User git
   # 走 HTTP 代理
   # ProxyCommand socat - PROXY:127.0.0.1:%h:%p,proxyport=7890
   # 走 socks5 代理
   # ProxyCommand nc -v -x 127.0.0.1:7890 %h %p
# 最新 亲测有效
Host github.com
  Hostname ssh.github.com
  Port 443
  User git
  ProxyCommand connect -S 127.0.0.1:7890 %h %p

results matching ""

    No results matching ""